package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Viewpoint;
import cn.wolfcode.luowowo.article.domain.ViewpointTag;
import cn.wolfcode.luowowo.article.mapper.ViewpointMapper;
import cn.wolfcode.luowowo.article.service.IViewpointService;
import cn.wolfcode.luowowo.common.query.ViewpointQueryObject;
import cn.wolfcode.luowowo.common.util.AjaxResult;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ViewpointServiceImpl implements IViewpointService {
    @Autowired
    private ViewpointMapper viewpointMapper;
//    @Override
//    public PageInfo query(QueryObject qo) {
//        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize(),qo.getOrderBy());
//        List<Viewpoint> list = viewpointMapper.selectForList(qo );
//        viewpointMapper.selectForList(qo);
//        return new PageInfo(list);
//    }

    @Override
    public Viewpoint get(Long id) {
        return viewpointMapper.selectByPrimaryKey(id);
    }





    @Override
    public AjaxResult saveOrUpdate(Viewpoint viewpoint) {

        return null;
    }

    @Override
    public List<Viewpoint> list() {
        return viewpointMapper.selectAll();
    }

    //推荐必游的5个景点
    public List<Viewpoint> listCommendViewpointTop5(Long destID) {
        return viewpointMapper.selectViewpointTop5(destID);
    }

    //热门景点
    public List<Viewpoint> listHotViewpoint(Long destId) {
        return viewpointMapper.selectHotViewpoint(destId);
    }

    //分页查询景点  pagesize = 15
    public PageInfo<Viewpoint> query(ViewpointQueryObject qo) {
        qo.setPageSize(5);
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<Viewpoint>(viewpointMapper.selectForList(qo));
    }

   //查询目的地下的景点标签
    public List<ViewpointTag> listTagsByDestId(Long destId) {
        return viewpointMapper.selectTagsByDestId(destId);
    }



}
